﻿/*中国有句俗语叫“三天打鱼两天晒网”，某人从1990年1月1日起
开始“三天打鱼两天晒网”，即工作三天，然后再休息两天。
问这个人在以后的某一天中是在工作还是在休息。
从键盘任意输入一天，编程判断他是在工作还是在休息，
如果是在工作，则输出：He is working，
如果是在休息，则输出：He is having a rest，
如果输入的年份小于1990或者输入的月份和日期不合法，
则输出：Invalid input。
输入格式: "%4d-%2d-%2d"
输出格式：
"Invalid input" 或
"He is having a rest" 或
"He is working"
输入样例1：
2014-12-22
输出样例1：
He is working
输入样例2：
2014-12-24
输出样例2：
He is having a rest
输入样例3：
2014-12-32
输出样例3：
Invalid input*/
#include <stdio.h>
#include<stdlib.h>
int main()
{
	int year, month,date, day = 0;
	while (scanf("%4d-%2d-%2d", &year, &month, &date) == 3 && year >= 1990
		&& (month > 0 && month <= 12))
	{
		year -= 1990;
		month--;
		day = 365 * year + year / 4 - year / 100 + year / 400+month*31-month/2+date-1;
		year++;
		if (month >= 2 && year % 4 == 0)//闰年2月为30-1
			day--;
		if (month >= 2 && year % 4 != 0)//非闰年2月为30-2
			day-=2;
		if (day % 5 < 3)
			puts("He is working");
		else
			puts("He is having a rest");
		printf("%d\n", day);
	}
	system("pause");
	return 0;
}
/*
int year, month, date, day = 0, ex = 0, a[5] = { 1, 1, 1, 0, 0 }, x = 0, i, j;
int mon1[13] = { 0, 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 },
mon2[13] = { 0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 };

if (year >= 1990)
{
if (month>0 && month <= 12)
{
if (year % 4 == 0)
{
if (date>0 && date <= mon1[month])
{
for (i = 1; i<month; i++)
ex = ex + mon1[i];
ex = ex + date;
day = ((year - 1992) / 4) * 1461 + 730 + ex;
x = day % 5;
if (a[x] == 1) printf("He is working");
else printf("He is having a rest");
}
else printf("Invalid input");
}
else
{
{
if (date>0 && date <= mon2[month])
{
for (i = 1; i<month; i++)
ex = ex + mon2[i];
for (j = year; j % 4 != 0; j--);
day = ((j - 1992) / 4) * 1461 + 730 + (year - j) * 365 + ex;
x = day % 5;
if (a[x] == 1) printf("He is working");
}
else printf("He is having a rest");
}
}
}
else printf("Invalid input");
}
else printf("Invalid input");
*/